import request from '@/utils/request'

// 查询盘点列表
export function listInventory(query) {
  return request({
    url: '/system/inventory/list',
    method: 'get',
    params: query
  })
}

// 查询盘点详细
export function getInventory(sessionNo) {
  return request({
    url: '/system/inventory/' + sessionNo,
    method: 'get'
  })
}

// 新增盘点
export function addInventory(data) {
  return request({
    url: '/system/inventory',
    method: 'post',
    data: data
  })
}

// 修改盘点
export function updateInventory(data) {
  return request({
    url: '/system/inventory',
    method: 'put',
    data: data
  })
}

// 删除盘点
export function delInventory(sessionNo) {
  return request({
    url: '/system/inventory/' + sessionNo,
    method: 'delete'
  })
}

// 执行盘点
export function executeInventory(data) {
  return request({
    url: '/system/inventory/execute',
    method: 'post',
    data: data
  })
}

// 导出盘点
export function exportInventory(query) {
  return request({
    url: '/system/inventory/export',
    method: 'get',
    params: query
  })
}

// 检查备件是否已在待盘点的盘点单中
export function checkPartsInPendingInventory(partNos) {
  return request({
    url: '/system/inventory/check-parts',
    method: 'get',
    params: { partNos: partNos.join(',') }
  })
}

// 获取所有待盘点盘点单中的备件编号
export function getPendingInventoryPartNos() {
  return request({
    url: '/system/inventory/pending-parts',
    method: 'get'
  })
}